package com.mark.mall.web.platform.controller;

import com.mark.mall.common.resultBean.R;
import com.mark.mall.web.platform.service.ElasticSearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author admin
 */
@RestController
@Slf4j
@Api(tags = "es索引操作")
@RequiredArgsConstructor
public class ElasticSearchController {
    private final ElasticSearchService elasticSearchService;

    @ApiOperation("创建es索引")
    @PostMapping("/createIndex")
    public R<Boolean> createIndex(String indexName) throws Exception {
        return elasticSearchService.createIndex(indexName);
    }

    @ApiOperation("同步es索引中数据")
    @PostMapping("/bulkGoods")
    public R<Boolean> bulkGoods() throws Exception {
        return elasticSearchService.bulkGoods();
    }

}
